package patrol.mobile.com.mobilepatrol.adapter;

import android.view.View;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import java.util.List;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.road_block.AssetTongzuxinxi;
import patrol.mobile.com.mobilepatrol.activity.road_block.RoadBlockActivity;

import static patrol.mobile.com.mobilepatrol.R.id.tv_retime;

/**
 * Created by long on 2016/8/24.
 * 巡道列表
 */
public class BlockListAdapter extends BaseQuickAdapter<AssetTongzuxinxi> {
    private RoadBlockActivity context;
//    private List<String> qlcodes = new ArrayList<>();
    public BlockListAdapter(RoadBlockActivity context, List<AssetTongzuxinxi> data) {
        super(context, data);
        this.context =  context;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_block;
    }

    @Override
    protected void convert(final BaseViewHolder holder, final AssetTongzuxinxi item) {
        holder.setText(R.id.index,item.index+"");
        holder.setText(R.id.tv_title, item.title);
        holder.setText(R.id.tv_time, item.blockTime);
        holder.setText(R.id.tv_affect_o, item.upDown);
        holder.setText(R.id.tv_road_status, item.status);

        if (item.isRetimeUp==0){
            holder.setText(R.id.tv_retime,"恢复\n畅通");
            holder.getView(tv_retime).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    context.alertReTime(item);
                }
            });
        }else{
            holder.setText(R.id.tv_retime,"已恢复");
        }
        //0没有上传
        if (item.reportingStatus.equals("未上报")){
            holder.setInVisible(R.id.iv_up,false);
            holder.setInVisible(R.id.iv_noup,true);
            holder.getView(R.id.iv_noup).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    context.upload(item);
                }
            });
        }else{
            holder.setInVisible(R.id.iv_up,true);
            holder.setInVisible(R.id.iv_noup,false);

        }

    }
}
